import { Input } from 'antd';
import { WECHAT_NUMBER } from '@/common/const';
import styles from './index.less';
import {useEffect, useState} from "react";
const Index = (props) => {
  const [val, setVal] = useState({
    qq: undefined,
    wx: undefined,
  })
  const onChange = (key: string, value: string) => {
    const newVal = {
      ...val,
      [key]: value
    }
    setVal(newVal)
    if(props.onChange){
      props.onChange(newVal)
    }
  }
  useEffect(() => {
    setVal({
      qq: props.value?.qq,
      wx: props.value?.wx,
    })
  }, [props.value])
  return (
    <div className={styles.container}>
      <Input addonBefore="QQ群：" placeholder="请输入" {...props} value={val?.qq} onChange={(evt) => onChange('qq', evt.target.value)} type="number" />
      <Input addonBefore="微信号：" placeholder="请输入" {...props} value={val?.wx} onChange={(evt) => onChange('wx', evt.target.value)} />
    </div>
  );
};

export default Index;
